import request from "@/utils/request";
import { R, page, PageQuery, emptyPageInfo } from "@/api/common/type";
import { Menu } from "@/api/menu/type";

enum API {
    MENU_TREE_URL = "/menu/tree",
    MENU_TREE_CONDITION_URL = "/menu/tree/condition",
    MENU_ONE_URL = "/menu/one",
    MENU_ADD_URL = "/menu/add",
    MENU_UPDATE_URL = "/menu/update",
    MENU_DEL_URL = "/menu/delete",
    MENU_ASSIGN_URL = "/menu/assign/menus",


}
 
//获取所有的权限tree
export const reqMenuTree = () => request.get<any, R<Menu[]>>(API.MENU_TREE_URL)

//获取用户所有的权限tree
export const reqMenuTreeByUser = (userId: number) => request.get<any, R<Menu[]>>(API.MENU_TREE_URL + "?userId=" + userId)

//获取动态条件的权限tree
export const reqMenuTreeByCondition = (data: any) => request.post<any, R<Menu[]>>(API.MENU_TREE_CONDITION_URL, data)

// 获取单个菜单信息
export const reqMenuOne = (id: number) => request.get<any, R<Menu>>(API.MENU_ONE_URL + `?id=` + id)

//新增菜单
export const reqMenuAdd = (data: any) => request.post<any, R<boolean>>(API.MENU_ADD_URL, data)

//编辑菜单
export const reqMenuUpdate = (data: any) => request.post<any, R<boolean>>(API.MENU_UPDATE_URL, data)

//删除菜单
export const reqMenuDel = (id: any) => request.delete<any, R<boolean>>(API.MENU_DEL_URL + `?id=` + id)

//角色分配菜单
export const reqAssignedMenu = (assignMenusDTO: any) => request.post<any, R<boolean>>(API.MENU_ASSIGN_URL, assignMenusDTO)